import {
  cookie
} from '@yjtec/cas-cookie';
import {
  getPageQuery,
  urlExcept
} from '../utils/utils';
export default function(data) {
  //写入cookie
  cookie.setCookie(data.ticket);
  //清楚当前url中的ticket
  setCurrentUrl();
}

function setCurrentUrl() {
  if (history && history.replaceState) {
    if (getPageQuery('ticket')) {
      history.replaceState(null, null, urlExcept('ticket', window.location.href));
    }
  }
}